global
    log         127.0.0.1 local2
    chroot      /var/lib/haproxy
    pidfile     /var/run/haproxy.pid
    maxconn     4000
    user        haproxy
    group       haproxy
    daemon
    stats socket /var/lib/haproxy/stats

defaults
    mode                   http
    log                     global
    option                  httplog
    option                  dontlognull
    option http-server-close
    option forwardfor       except 127.0.0.0/8
    option                  redispatch
    retries                 3
    timeout http-request    10s
    timeout queue           1m
    timeout connect         10s
    timeout client          1m
    timeout server          1m
    timeout http-keep-alive 10s
    timeout check           10s
    maxconn               4000

listen  haproxy_stats-{{ hostvars[inventory_hostname]['ansible_' + dashboard_iface].ipv4.address }}-8888
        mode http
        bind {{ hostvars[inventory_hostname]['ansible_' + dashboard_iface].ipv4.address }}:8888
        option httplog
        stats refresh 30s
        stats uri /status
        stats realm Haproxy Manager
        stats auth admin:{{HAPROXY_PASS}}

listen haproxy_cluster-{{API_VIP}}-8888
  bind {{ DASHBOARD_VIP }}:8888
  mode                    http
  balance                 source
{% for item in groups['controller'] %}
  server {{ hostvars[item]['ansible_hostname'] }} {{ hostvars[item]['ansible_' + dashboard_iface].ipv4.address }}:8888 check inter 2000 rise 2 fall 5 
{% endfor %}

listen galera_cluster-{{API_VIP}}-3306
  bind {{API_VIP}}:3306
  mode                    http
  balance                 source
{% for item in groups['controller'] %}
  server {{ hostvars[item]['ansible_hostname'] }} {{ hostvars[item]['ansible_' + api_iface].ipv4.address }}:3306 check inter 2000 rise 2 fall 5 {% if hostvars[item]['ansible_hostname']==cluster_master_hostname  %}backup weight 0
{% elif hostvars[item]['ansible_hostname']==cluster_backup1_hostname %} 
{% else %}backup
{% endif %}
{% endfor %}

listen rabbitMQ_cluster-{{API_VIP}}-5672
  bind {{API_VIP}}:5672
  mode                    http
  balance                 source
{% for item in groups['controller'] %}
  server {{ hostvars[item]['ansible_hostname'] }} {{ hostvars[item]['ansible_' + api_iface].ipv4.address }}:5672 check inter 2000 rise 2 fall 5 
{% endfor %}

listen memcache-{{API_VIP}}-11211
  bind  {{API_VIP}}:11211
  balance  source
  mode     http
{% for item in groups['controller'] %}
  server {{ hostvars[item]['ansible_hostname'] }} {{ hostvars[item]['ansible_' + api_iface].ipv4.address }}:11211 check inter 2000 rise 2 fall 5 
{% endfor %}

listen keystone_admin_cluster-{{API_VIP}}-35357
  bind {{API_VIP}}:35357
  balance  source
  option  tcpka
  option  httpchk
  option  tcplog
{% for item in groups['controller'] %}
  server {{ hostvars[item]['ansible_hostname'] }} {{ hostvars[item]['ansible_' + api_iface].ipv4.address }}:35357 check inter 2000 rise 2 fall 5 
{% endfor %}

listen keystone_public_internal_cluster-{{API_VIP}}-5000
  bind {{API_VIP}}:5000
  balance  source
  option  tcpka
  option  httpchk
  option  tcplog
{% for item in groups['controller'] %}
  server {{ hostvars[item]['ansible_hostname'] }} {{ hostvars[item]['ansible_' + api_iface].ipv4.address }}:5000 check inter 2000 rise 2 fall 5 
{% endfor %}

listen glance_api_cluster-{{API_VIP}}-9292
  bind {{API_VIP}}:9292
  balance  source
  option  tcpka
  option  httpchk
  option  tcplog
{% for item in groups['controller'] %}
  server {{ hostvars[item]['ansible_hostname'] }} {{ hostvars[item]['ansible_' + api_iface].ipv4.address }}:9292 check inter 2000 rise 2 fall 5 
{% endfor %}

listen glance_registry_cluster-{{API_VIP}}-9191
  bind {{API_VIP}}:9191
  balance  source
  option  tcpka
  option  tcplog
{% for item in groups['controller'] %}
  server {{ hostvars[item]['ansible_hostname'] }} {{ hostvars[item]['ansible_' + api_iface].ipv4.address }}:9191 check inter 2000 rise 2 fall 5 
{% endfor %}

listen nova_compute_api_cluster-{{API_VIP}}-8774
  bind {{API_VIP}}:8774
  balance  source
  option  tcpka
  option  httpchk
  option  tcplog
{% for item in groups['controller'] %}
  server {{ hostvars[item]['ansible_hostname'] }} {{ hostvars[item]['ansible_' + api_iface].ipv4.address }}:8774 check inter 2000 rise 2 fall 5 
{% endfor %}

listen nova_metadata_api_cluster-{{API_VIP}}-8775
  bind {{API_VIP}}:8775
  balance  source
  option  tcpka
  option  tcplog
{% for item in groups['controller'] %}
  server {{ hostvars[item]['ansible_hostname'] }} {{ hostvars[item]['ansible_' + api_iface].ipv4.address }}:8775 check inter 2000 rise 2 fall 5 
{% endfor %}

listen nova_vncproxy_cluster-{{DASHBOARD_VIP}}-6080
  bind {{DASHBOARD_VIP}}:6080
  balance  source
  option  tcpka
  option  tcplog
{% for item in groups['controller'] %}
  server {{ hostvars[item]['ansible_hostname'] }} {{ hostvars[inventory_hostname]['ansible_' + dashboard_iface].ipv4.address }}:6080 check inter 2000 rise 2 fall 5 
{% endfor %}

listen neutron_api_cluster-{{API_VIP}}-9696
  bind {{API_VIP}}:9696
  balance  source
  option  tcpka
  option  httpchk
  option  tcplog
{% for item in groups['controller'] %}
  server {{ hostvars[item]['ansible_hostname'] }} {{ hostvars[item]['ansible_' + api_iface].ipv4.address }}:9696 check inter 2000 rise 2 fall 5 
{% endfor %}

listen cinder_api_cluster-{{API_VIP}}-8776
  bind {{API_VIP}}:8776
  balance  source
  option  tcpka
  option  httpchk
  option  tcplog
{% for item in groups['controller'] %}
  server {{ hostvars[item]['ansible_hostname'] }} {{ hostvars[item]['ansible_' + api_iface].ipv4.address }}:8776 check inter 2000 rise 2 fall 5 
{% endfor %}

listen ceilometer_api_cluster-{{API_VIP}}-8777
  bind {{API_VIP}}:8777
  balance  source
  option  tcpka
  option  tcplog
{% for item in groups['controller'] %}
  server {{ hostvars[item]['ansible_hostname'] }} {{ hostvars[item]['ansible_' + api_iface].ipv4.address }}:8777 check inter 2000 rise 2 fall 5 
{% endfor %}

listen heat_api_cluster-{{API_VIP}}-8004
  bind {{API_VIP}}:8004
  balance  source
  option  tcpka
  option  tcplog
{% for item in groups['controller'] %}
  server {{ hostvars[item]['ansible_hostname'] }} {{ hostvars[item]['ansible_' + api_iface].ipv4.address }}:8004 check inter 2000 rise 2 fall 5
{% endfor %}

listen heat_aws_api_cluster-{{API_VIP}}-8000
  bind {{API_VIP}}:8000
  balance  source
  option  tcpka
  option  tcplog
{% for item in groups['controller'] %}
  server {{ hostvars[item]['ansible_hostname'] }} {{ hostvars[item]['ansible_' + api_iface].ipv4.address }}:8000 check inter 2000 rise 2 fall 5
{% endfor %}

listen mongodb-{{API_VIP}}-27017
  bind {{API_VIP}}:27017
  mode     http
  balance  source
{% for item in groups['controller'] %}
  server {{ hostvars[item]['ansible_hostname'] }} {{ hostvars[item]['ansible_' + api_iface].ipv4.address }}:27017 check inter 2000 rise 2 fall 5
{% endfor %}

listen horizon_cluster-{{DASHBOARD_VIP}}-80
  bind  {{DASHBOARD_VIP}}:80
  mode     http
  balance  source
  option  tcpka
  option  httpchk
  option  tcplog
{% for item in groups['controller'] %}
  server {{ hostvars[item]['ansible_hostname'] }} {{ hostvars[item]['ansible_' + dashboard_iface].ipv4.address }}:80 check inter 2000 rise 2 fall 5 
{% endfor %}

listen register-{{DASHBOARD_VIP}}-81
   bind {{DASHBOARD_VIP}}:81
   mode     http
   balance  source
   option  tcpka
   option  httpchk
   option  tcplog
{% for item in groups['controller'] %}
   server {{ hostvars[item]['ansible_hostname'] }} {{ hostvars[item]['ansible_' + dashboard_iface].ipv4.address }}:81 check inter 2000 rise 2 fall 5
{% endfor %}

listen union-{{DASHBOARD_VIP}}-8080
    bind {{DASHBOARD_VIP}}:8080
    mode     http
    balance  source
    option  tcpka
    option  httpchk
    option  tcplog
{% for item in groups['controller'] %}
    server {{ hostvars[item]['ansible_hostname'] }} {{ hostvars[item]['ansible_' + dashboard_iface].ipv4.address }}:8080 check inter 2000 rise 2 fall 5
{% endfor %}
